import config from '@/config'
import RequestBase from '@/utils/request.js'

const safetyRequest = new RequestBase(config.safetyUrl)
const basicRequest = new RequestBase(config.basicInfoUrl)
const baseRequest = new RequestBase(config.baseUrl)
const doubleDefenseRequest = new RequestBase(config.doubleDefenseUrl)
// 查询用户列表(包含子部门)
export const listUser = (data) => {
  data.containChildren = true
  data.pageSize = 9999
  return baseRequest.get('/portal/auth/staff/api/v1/list', data).then((res) => {
    res.data.map((item) => {
      item.name = item.staffName
      item.userId = item.staffId
      return item
    })
    return res
  })
}

// 查询用户列表(包含子部门)
export const listUserPaging = (data) => {
  data.containChildren = true
  data.pageSize = 20
  return baseRequest.get('/portal/auth/staff/api/v1/page', data)
}

// 查询用户列表(包含子部门)
export const listUserPagingV2 = (data) => {
  return baseRequest.get('/portal/auth/staff/api/v1/page', data).then((res) => {
    res.rows.map((item) => {
      item.userId = item.staffId
      item.name = item.staffName
      return item
    })
    return res
  })
}

/*承包商台账*/
export const contractorUsrList = (data) => {
  // /api/safety/bsci/contractor-in-stock-member/list
  data.presentStatus = 1
  data.pageSize = 20
  return safetyRequest.get('/bsci/contractor-in-stock-member/list', data)
  // return safetyRequest.get('/mobile/bsci/staff/simple-list', data);
}
/*承包商用户*/
export const contractorAccUsrList = (data) => {
  data.pageSize = 20
  return safetyRequest.get('/mobile/bsci/staff/simple-list', data)
}

// 查询部门用户列表(不包含子部门)
export const listDeptUser = (data) => {
  data.pageSize = 9999
  return baseRequest.get('/portal/auth/staff/api/v1/list', data).then((res) => {
    res.data.map((item) => {
      item.name = item.staffName
      item.userId = item.staffId
      return item
    })
    return res
  })
}

// 获取当前登录用户信息
export const getUserInfo = () => {
  return basicRequest.get('/basic/app/login-staff')
}

// 岗位职责
export const getPostDuty = (userId) => {
  return safetyRequest.get(`/bsci/dept-post/queryUserPostDuty/${userId}`)
}

// 个人评价
export const getAssess = () => {
  return safetyRequest.get(`/mobile/bsci/staff/evaluation/list`)
}

// 资质证书
export const getQualification = () => {
  return safetyRequest.get(`/mobile/bsci/staff/qualification/list`)
}

// 根据id获取用户信息
export const getStaffQuery = (id) => {
  return baseRequest.get(`/portal/auth/staff/api/v1/detail/${id}`)
}

// 监护人/负责人列表
export const changePersonList = (data) => {
  return basicRequest.get(`/info/web/staff/getByQualification/${data.qualityValueList}`, data)
}
